// 普通函数的写法
type MyFn1 = (name: "changeNum" | "changeStr", value: number | string) => void;
const fn1: MyFn1 = (name, value) => {};

fn1("changeNum", "1");
fn1("changeNum", 1);
fn1("changeStr", "1");

// TS：函数调用签名类型
// 原理：万物皆对象， 函数也属于对象类型
// 优势： 比联合类型， 更加准确的指定参数的类型
export interface MyFn {
  (name: "changeNum", value: number): void;
  (name: "changeStr", value: string): void;
}

const fn: MyFn = (name, value) => {};
fn("changeNum", 1);

// fn("changeStr", 2);
